package com.atguigu.eduservice.controller;

import com.atguigu.commonutils.R;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther 赵乾坤
 * @Date 2021-06-28 18:36
 */
@Api(description = "模拟登录")
@RestController
@RequestMapping("/eduuser")//前端在src/api/login.js 16行
@CrossOrigin//跨域 跨域问题：协议、地址、端口
//nginx反向代理地址  http://localhost:8001/user/info?token=admin
public class EduLoginController {

    @PostMapping("login")
    @ApiOperation("模拟登录")
    @ApiOperationSupport(author = "zqk", order = 1)
    public R login() {
        //返回：{"code":20000,"data":{"token":"admin"}}
        //R.ok 就是200
        return R.ok().data("token", "admin");
    }

    @GetMapping("info")
    @ApiOperation("或许用户信息")
    @ApiOperationSupport(author = "zqk", order = 2)
    public R getInfo() {
        //返回{"code":20000,"data":{"roles":["admin"],"name":"admin","avatar":"https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif"}}
        return R.ok().data("roles","admin")
                .data("name","admin")
                .data("avatar","https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");//头像； avatarcc
    }

}
